/*
Run this script on:

        mssql-ct.db.jwan.it,1433.Caronte2014    -  This database will be modified

to synchronize it with:

        kalgan01.cs.jwan.it,1443.Jambo2014_sviluppo

You are recommended to back up your database before running this script

Script created by SQL Compare version 9.0.0 from Red Gate Software Ltd at 11/04/2014 16:32:11

*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
PRINT N'Dropping foreign keys from [dbo].[jb_configscontiresidenti]'
GO
ALTER TABLE [dbo].[jb_configscontiresidenti] DROP
CONSTRAINT [FK_jb_configScontiCatego_sconti],
CONSTRAINT [FK_jb_configScontiCatego_res_sconti]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[jb_configScontiResidenti]'
GO
ALTER TABLE [dbo].[jb_configScontiResidenti] ADD
CONSTRAINT [FK_jb_configScontiCatego_sconti] FOREIGN KEY ([CODSCO]) REFERENCES [dbo].[sconti] ([CODSCO]),
CONSTRAINT [FK_jb_configScontiCatego_res_sconti] FOREIGN KEY ([CODSCO_RES]) REFERENCES [dbo].[sconti] ([CODSCO])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[prezzi]'
GO
ALTER TABLE [dbo].[prezzi] ADD
CONSTRAINT [FK_prezzi_catego] FOREIGN KEY ([CATKEY]) REFERENCES [dbo].[catego] ([CATKEY])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT 'The database update succeeded'
COMMIT TRANSACTION
END
ELSE PRINT 'The database update failed'
GO
DROP TABLE #tmpErrors
GO
